<?php


namespace App\Services;


use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Cache;

trait AuthUser
{
    /**
     * 获取登录用户ID
     * @return int
     */
    public function getAuthUserId()
    {
        $user = $this->getAuthUser();
        return $user['id'];
    }


    /**
     * 获取手机
     * @return string
     */
    public function getAuthPhone()
    {
        $user = $this->getAuthUser();
        return $user['phone'] ?? '';
    }

    /**
     * 获取手机
     * @return string
     */
    public function getAuthEmail()
    {
        $user = $this->getAuthUser();
        return $user['email'] ?? '';
    }

    /**
     * 获取公司ID
     * @return int
     */
    public function getAuthApiToken()
    {
        $user = $this->getAuthUser();
        return $user['api_token'];
    }

    /**
     * 获取登录用户
     * @return \Illuminate\Contracts\Auth\Authenticatable|null
     */
    public function getAuthUser()
    {
        // todo 用redis缓存来获取
        $user = Auth::user();
        return $user;
    }

    public function getAuthUserType()
    {
        $user = Auth::user();
        return $user['exhibitor_category'] ?? '';
    }

}
